package attend.com;

import java.util.HashMap;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import attend.UserContainer.User;
import attend.UserContainer.UserAware;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class Session extends ActionSupport implements SessionAware , UserAware {
	
	protected Map 						session 	=	ActionContext.getContext().getSession();
	
	protected String 					sessionTime;
	
	protected String 					user_id;
	protected String 					pass;
	
	protected HashMap<String, String> 	empInfo;
	

	protected User 						user 		= null;
	
	
	public Session() {	}

	/**
	 * @return
	 */
	public Boolean isSeesion() {
		
		boolean flag = false;
		try {
			
			user = (User)session.get("user");
		
			if (user == null ||session == null || !session.containsKey("user") || user.getEmpInfo().size() == 0) {
				flag = false;
			} else {
				flag = true;
			}
		} catch (NullPointerException e) {
			flag = false;
		}
		
		return flag;
	}
	
	/******************************************************************************/
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Map getSession() {
		return session;
	}

	//@Override
	public void setSession(Map session) {
		session = this.session;
	}
	
	public HashMap<String, String> getEmpInfo() {
		return empInfo;
	}
	
	public void setEmpInfo(HashMap<String, String> empInfo) {
		this.empInfo = empInfo;
	}
	
	public String getSessionTime() {
		return sessionTime;
	}

	public void setSessionTime(String sessionTime) {
		this.sessionTime = sessionTime;
	}

	public String getPass() {
		return pass;
	}
	
	public void setPass(String pass) {
		this.pass = pass;
	}
	
	public String getUser_id() {
		return user_id;
	}

	public void setUser_id(String user_id) {
		this.user_id = user_id;
	}	
	/******************************************************************************/
}
